/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package server.so.trening;

import domen.OpstiDomenskiObjekat;
import domen.Trening;
//import java.sql.SQLException;
//import java.util.logging.Level;
//import java.util.logging.Logger;
import server.baza.DataBaseBroker;
import server.so.OpstaSO;

/**
 *
 * @author Ivan Ivic
 */
public class VratiTrening extends OpstaSO {
    private Trening trening;

    public Trening getTrening() {
        return trening;
    }

    public void setTrening(Trening trening) {
        this.trening = trening;
    }

    public synchronized static Trening vratiTrening(String sifraTreninga)
    {
        VratiTrening vt = new VratiTrening();
        Trening t = new Trening();
        t.setSifraTreninga(sifraTreninga);
        vt.opsteIzvrsenjeSO(t);
        return vt.getTrening();
    }

    @Override
    public int izvrsenjeSO(OpstiDomenskiObjekat odo) {
        Trening t = (Trening) odo;
        trening = (Trening) DataBaseBroker.getDbb().vrati(t);
        //signal = 9017;
        signal = DataBaseBroker.getDbb().getSignal();
        return signal;
    }

    @Override
    public boolean stanjeOperacije(int signal) {
        switch(signal)
        {
            case 9017:
                prikazi(signal, "Slog vracen");
                return true;
            case 9018:
                prikazi(signal, "Slog ne moze da bude vracen");
                return false;
            default:
                return false;
        }
    }
}
